﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Core;

namespace DAL
{
    public class RePutQuestionDAL : SyncBase<Model.RePutQuestion>
    {
        static RePutQuestionDAL()
        {
            StringBuilder strSql = new StringBuilder();
            RePutQuestionDAL.addSQL = @"insert into TempRePutQuestion(
TeacherID,LessionID,FeedType,PutQutionTime,TimePiont,IsEnd,RecordTime)
 values (
@TeacherID,@LessionID,@FeedType,@PutQutionTime,@TimePiont,@IsEnd,@RecordTime)";
            RePutQuestionDAL.tbName = "TempRePutQuestion";
            RePutQuestionDAL.remoteUrl = "/Ayyfford/AddRePutQuestion";
            RePutQuestionDAL.setVal = (lt) =>
            {
                StringBuilder sb = new StringBuilder();
                string _ids = string.Empty;
                if (lt != null && lt.Count > 0)
                {
                    lt.ForEach(t =>
                    {
                        _ids += t.ID + ",";
                        sb.AppendFormat("({0}, {1}, {2},{3}, {4}, {5}, {6}),",
                            t.TeacherID.NullNumber(), t.LessionID.NullNumber(), t.FeedType.NullNumber(), t.PutQutionTime.NullDate(), t.TimePiont.NullNumber(), t.IsEnd ? 1 : 0, t.RecordTime.NullDate());
                    });
                }
                return new Tuple<string, string>(sb.ToString(), _ids);
            };
        }

        new public static void SaveEntity(Model.RePutQuestion t)
        {
            SyncBase<Model.RePutQuestion>.SaveEntity(t);
        }

        new public static void AsyncData()
        {
            SyncBase<Model.RePutQuestion>.AsyncData();
        }
    }
}
